<?php


namespace app\common\controller;


use app\common\service\getPhoneInfoService;
use think\facade\Request;

class Info
{
    /**
     * 获取单个手机号码的贷款详情
     * @param $phone 手机号码
     * @param $type 贷款分类
     * @return \think\response\Json
     * @throws \app\lib\exception\ParameterException
     */
    public function getPhoneInfo($phone, $type, $logo)
    {
        $common = new RegisteredPhone();
        # 得到原始数据
        $result_arr = $common->getRegisteredPhoneMoney([$phone], $type, $logo);
        # 对原始查询出来的数据进行组装
        $service = new getPhoneInfoService();
        $data = $service->getPhoneMoneyDate($result_arr);
        if($type == 'd'){
            $result = $service->htmlD($data, $phone);
        }elseif ($type == 'f'){
            $result = $service->htmlF($data, $phone);
        }
        return json([
            'html' => $result['html'],
            'data' => $result['data']
        ]);
    }

    /**
     * 检查手机是否在改商户注册过
     * @param $phone 一个手机号码
     * @param $type 贷款类型
     * @param $logo 商家标识
     * @return mixed
     * @throws \app\lib\exception\ParameterException
     */
    public function checkPhone($phone, $type, $logo)
    {
        $common = new RegisteredPhone();
        $result_arr = $common->getRegisteredPhoneMoney([$phone], $type, $logo);
        $service = new getPhoneInfoService();
        $data = $service->checkHasPhone($result_arr);
        return $data;
    }
}